﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace RestfulApi.Filters
{
    public class MyResultFilterAttribute : Attribute, IResultFilter
    {
        public MyResultFilterAttribute(ILogger<MyResultFilterAttribute> logger)
        {
            Logger = logger;
        }

        public ILogger<MyResultFilterAttribute> Logger { get; }

        public void OnResultExecuted(ResultExecutedContext context)
        {
            //Logger.LogInformation("OnResultExecuted executes.");
            //throw new Exception("OnResultExecuted"); //不能
        }

        public void OnResultExecuting(ResultExecutingContext context)
        {
            //Logger.LogInformation("OnResultExecuting executes.");
            //throw new Exception("OnResultExecuting"); 不能
        }
    }
}
